
function creationMonth(workPlanTitle,titleName){
		$("#remarks").attr("style", "display:blank;");
		$("#typeContent").attr("style", "display:blank;");
		
	 titleName = $("#month").val();
	 //var workPlanTitle ="";
	 
	  // 设置calendar div中的html部分
	  renderHtml();
	  // 表格中显示日期
	  showCalendarData();
	  // 绑定事件
	 // bindEvent();
	 
	  /**
	   * 渲染html结构
	   */
	  function renderHtml() {
	    var calendar = document.getElementById("calendar");
	    var titleBox = document.createElement("div");  // 标题盒子 设置上一月 下一月 标题
	    var bodyBox = document.createElement("div");  // 表格区 显示数据
	 
	    // 设置标题盒子中的html
	    titleBox.className = 'calendar-title-box';
	    titleBox.innerHTML = //"<span class='prev-month' id='prevMonth'></span>" +
	      "<span class='calendar-title' id='calendarTitle'></span>" 
	     // "<span id='nextMonth' class='next-month'></span>";
	    calendar.appendChild(titleBox);    // 添加到calendar div中
	 
	    // 设置表格区的html结构
	    bodyBox.className = 'calendar-body-box';
	    var _headHtml = "<tr >" + 
	              "<th style='text-align:center'>日</th>" +
	              "<th style='text-align:center'>一</th>" +
	              "<th style='text-align:center'>二</th>" +
	              "<th style='text-align:center'>三</th>" +
	              "<th style='text-align:center'>四</th>" +
	              "<th style='text-align:center'>五</th>" +
	              "<th style='text-align:center'>六</th>" +
	            "</tr>";
	    var _bodyHtml = "";
	
	 
	    // 一个月最多31天，所以一个月最多占6行表格
	    for(var i = 0; i < 6; i++) {  
	      _bodyHtml += "<tr>" +
	              "<td></td>" +
	              "<td></td>" +
	              "<td></td>" +
	              "<td></td>" +
	              "<td></td>" +
	              "<td></td>" +
	              "<td></td>" +
	            "</tr>";
	    }
	    bodyBox.innerHTML = "<table id='calendarTable' class='calendar-table'>" +
	              _headHtml + _bodyHtml +
	              "</table>";
	    // 添加到calendar div中
	    calendar.appendChild(bodyBox);
	  }
	 
	  /**
	   * 表格中显示数据，并设置类名
	   */
	  function showCalendarData() {
	    var _year =titleName.substr(0,4) //dateObj.getDate().getFullYear();
	    var _month = titleName.substr(5,2)//dateObj.getDate().getMonth() + 1;
		if(_month.indexOf("月")==1){
		_month = _month.substr(0,1);
		}
		/* if(){
			
		} */
	    var _dateStr = getDateStr(dateObj.getDate());
	 
	    // 设置顶部标题栏中的 年、月信息
	    var calendarTitle = document.getElementById("calendarTitle");
	    var titleStr = _year + "年" + _month+ "月";
	    calendarTitle.innerText = titleStr;
	 
	    // 设置表格中的日期数据
	    var _table = document.getElementById("calendarTable");
	    var _tds = _table.getElementsByTagName("td");
	    var _firstDay = new Date(_year, _month - 1, 1);  // 当前月第一天
	    for(var i = 0; i < _tds.length; i++) {
	      var _thisDay = new Date(_year, _month - 1, i + 1 - _firstDay.getDay());
	      var _thisDayStr = getDateStr(_thisDay);
	      _tds[i].innerText = _thisDay.getDate();
	      //_tds[i].data = _thisDayStr;
	      _tds[i].setAttribute('data', _thisDayStr);
	      if(_thisDayStr.substr(0, 6) == getDateStr(_firstDay).substr(0, 6)) {
			   var c=0;
			   _tds[i].className = 'all day0';
			  for(var w = 0;w<workPlanTitle.length;w++){
				  
				 c++;
				if(c<10){
					c="0"+c;
				}
				if(_thisDayStr.substr(6, 8) ==c){
					 _tds[i].id=workPlanTitle[w].id;
					if("1"== workPlanTitle[w].day1){
						_tds[i].className = ' all mohthGetCashbox';
						 _tds[i].style="border:1px solid red ;"
						 _tds[i].innerHTML=_tds[i].innerHTML+'<span class="qwe"  style="font-size: 5px;"  >去</span>'
					}else{
						
					}
					
					if("2"== workPlanTitle[w].day1){
						_tds[i].className = 'mohthGetCashbox2';
						 _tds[i].style="border:1px solid red ;"
						 _tds[i].innerHTML=_tds[i].innerHTML+'<span class="qwe"  style="font-size: 5px;"  >加急</span>'
					}
				}
			  }
			  
	       
	      }else {    // 其他月
	        _tds[i].className = 'otherMonth';
	      }
	    }
	  }
	 
	  /**
	   * 绑定上个月下个月事件
	   */
	  function bindEvent() {
	    var prevMonth = document.getElementById("prevMonth");
	    var nextMonth = document.getElementById("nextMonth");
	    addEvent(prevMonth, 'click', toPrevMonth);
	    addEvent(nextMonth, 'click', toNextMonth);
	  }
	 
	  /**
	   * 绑定事件
	   */
	  function addEvent(dom, eType, func) {
	    if(dom.addEventListener) {  // DOM 2.0
	      dom.addEventListener(eType, function(e){
	        func(e);
	      });
	    } else if(dom.attachEvent){  // IE5+
	      dom.attachEvent('on' + eType, function(e){
	        func(e);
	      });
	    } else {  // DOM 0
	      dom['on' + eType] = function(e) {
	        func(e);
	      }
	    }
	  }
	 
	  /**
	   * 点击上个月图标触发
	   */
	  function toPrevMonth() {
	    var date = dateObj.getDate();
	    dateObj.setDate(new Date(date.getFullYear(), date.getMonth() - 1, 1));
	    showCalendarData();
	  }
	 
	  /**
	   * 点击下个月图标触发
	   */
	  function toNextMonth() {
	    var date = dateObj.getDate();
	    dateObj.setDate(new Date(date.getFullYear(), date.getMonth() + 1, 1));
	    showCalendarData();
	  }
	 
	  /**
	   * 日期转化为字符串， 4位年+2位月+2位日
	   */
	  function getDateStr(date) {
	    var _year = date.getFullYear();
	    var _month = date.getMonth() + 1;    // 月从0开始计数
	    var _d = date.getDate();
	     
	    _month = (_month > 9) ? ("" + _month) : ("0" + _month);
	    _d = (_d > 9) ? ("" + _d) : ("0" + _d);
	    return _year + _month + _d;
	  }
	  var stepType = "company";
	  if("company"==stepType){
		  var table = document.getElementById("calendarTable");
		  var tds = table.getElementsByTagName('td');
		  for(var i = 0; i < tds.length; i++) {
		    addEvent(tds[i], 'click', function(e){
		  			var tdById= document.getElementById(e.target.getAttribute('id'));
		  		  if(e.target.getAttribute('class')=="all day0"){
					tdById.className = ' all mohthGetCashbox';
		  			tdById.style="border:1px solid red ;"
		  			tdById.innerHTML=tdById.innerHTML+'<span style="font-size: 5px;"  >去</span>'
		  		  }else if(e.target.getAttribute('class')=="mohthGetCashbox2"){
		  			
		  		  }else{
		  			  tdById.className="all day0";
		  			  tdById.style=""
		  			  if(tdById.innerHTML.substr(0,2).indexOf("<")=="1"){
		  				   tdById.innerHTML=tdById.innerHTML.substr(0,1)
		  			  }else{
		  				   tdById.innerHTML=tdById.innerHTML.substr(0,2)
		  			  }
		  		  }
		    });
		  }
	  }
	 
}













function queryTableLeft(titleName){
	var companyId = $("#comId").val();
	var officeId = $("#toId").val();
	if(titleName==null||titleName==""){
		titleName = $("#queryMonth").val();
	}
	if( typeof(titleName) == "undefined"){
		titleName = $("#queryMonth").val();
	}
	if(companyId==null||companyId==""){
		alert("请选择公司")
		return;
	}
	if(officeId==null||officeId==""){
		alert("票务室")
		return;
	}
	
	
		$.ajax({
			type: 'post',
			url:reportForm+'workPlan/getWorkPlanByComAndOffAndSerialNumber',
			data: {
				companyId:companyId,
				officeId:officeId,
				//serialNumber:serialNumber,
				titleName:titleName
			},
			dataType: 'json',
			success: function(data){
				$("#calendarLeft").empty();
				var workPlanTitle= data.workPlanList 
				 calendarLeft(workPlanTitle,titleName);
			},
			error:function(data) {
				console.log(data.msg);
			},
		});

}


function calendarLeft(workPlanTitle,titleName){
	 titleName = $("#queryMonth").val();
	 //var workPlanTitle ="";
	  // 设置calendar div中的html部分
	  renderHtml();
	  // 表格中显示日期
	  showCalendarData();
	  // 绑定事件
	 // bindEvent();
	 
	  /**
	   * 渲染html结构
	   */
	  function renderHtml() {
	    var calendar = document.getElementById("calendarLeft");
	    var titleBox = document.createElement("div");  // 标题盒子 设置上一月 下一月 标题
	    var bodyBox = document.createElement("div");  // 表格区 显示数据
	 
	    // 设置标题盒子中的html
	    titleBox.className = 'calendar-title-box';
	    titleBox.innerHTML = //"<span class='prev-month' id='prevMonth'></span>" +
	      "<span class='calendar-title' id='calendarTitleLeft'></span>" 
	     // "<span id='nextMonth' class='next-month'></span>";
	    calendar.appendChild(titleBox);    // 添加到calendar div中
	 
	    // 设置表格区的html结构
	    bodyBox.className = 'calendar-body-box';
	    var _headHtml = "<tr >" + 
	              "<th style='text-align:center'>日</th>" +
	              "<th style='text-align:center'>一</th>" +
	              "<th style='text-align:center'>二</th>" +
	              "<th style='text-align:center'>三</th>" +
	              "<th style='text-align:center'>四</th>" +
	              "<th style='text-align:center'>五</th>" +
	              "<th style='text-align:center'>六</th>" +
	            "</tr>";
	    var _bodyHtml = "";
	
	 
	    // 一个月最多31天，所以一个月最多占6行表格
	    for(var i = 0; i < 6; i++) {  
	      _bodyHtml += "<tr>" +
	              "<td></td>" +
	              "<td></td>" +
	              "<td></td>" +
	              "<td></td>" +
	              "<td></td>" +
	              "<td></td>" +
	              "<td></td>" +
	            "</tr>";
	    }
	    bodyBox.innerHTML = "<table id='calendarTableLeft' class='calendar-table'>" +
	              _headHtml + _bodyHtml +
	              "</table>";
	    // 添加到calendar div中
	    calendar.appendChild(bodyBox);
	  }
	 
	  /**
	   * 表格中显示数据，并设置类名
	   */
	  function showCalendarData() {
	    var _year =titleName.substr(0,4) //dateObj.getDate().getFullYear();
	    var _month = titleName.substr(4,2)//dateObj.getDate().getMonth() + 1;
		if(_month.indexOf("月")==1){
		_month = _month.substr(0,1);
		}
		/* if(){
			
		} */
	    var _dateStr = getDateStr(dateObj.getDate());
	 
	    // 设置顶部标题栏中的 年、月信息 calendarTitleFelt
	    var calendarTitle = document.getElementById("calendarTitleLeft");
	    var titleStr = _year + "年" + _month+ "月";
	    calendarTitle.innerText = titleStr;
	 
	    // 设置表格中的日期数据
	    var _table = document.getElementById("calendarTableLeft");
	    var _tds = _table.getElementsByTagName("td");
	    var _firstDay = new Date(_year, _month - 1, 1);  // 当前月第一天
	    for(var i = 0; i < _tds.length; i++) {
	      var _thisDay = new Date(_year, _month - 1, i + 1 - _firstDay.getDay());
	      var _thisDayStr = getDateStr(_thisDay);
	      _tds[i].innerText = _thisDay.getDate();
	      //_tds[i].data = _thisDayStr;
	      _tds[i].setAttribute('data', _thisDayStr);
	      if(_thisDayStr.substr(0, 6) == getDateStr(_firstDay).substr(0, 6)) {
			   var c=0;
			 //  _tds[i].className = 'all day0';
			// console.log("123")
			    _tds[i].className = 'currentMonth'; 
			  for(var w = 0;w<workPlanTitle.length;w++){
				 c++;
				if(c<10){
					c="0"+c;
				}
				if(_thisDayStr.substr(6, 8) ==c){
					 _tds[i].id=workPlanTitle[w].id;
					if("1"== workPlanTitle[w].day1){
						_tds[i].className = 'mohthGetCashbox';
						 _tds[i].style="border:1px solid red ;"
						 _tds[i].innerHTML=_tds[i].innerHTML+'<span class="qwe"  style="font-size: 5px;"  >去</span>'
					}else{
						
					}
					
					if("2"== workPlanTitle[w].day1){
						_tds[i].className = 'mohthGetCashbox2';
						 _tds[i].style="border:1px solid red ;"
						 _tds[i].innerHTML=_tds[i].innerHTML+'<span class="qwe"  style="font-size: 5px;"  >加急</span>'
					}
				}
			  }
			  
	       
	      }else {    // 其他月
	        _tds[i].className = 'otherMonth';
	      }
	    }
	  }
	 
	  /**
	   * 日期转化为字符串， 4位年+2位月+2位日
	   */
	  function getDateStr(date) {
	    var _year = date.getFullYear();
	    var _month = date.getMonth() + 1;    // 月从0开始计数
	    var _d = date.getDate();
	     
	    _month = (_month > 9) ? ("" + _month) : ("0" + _month);
	    _d = (_d > 9) ? ("" + _d) : ("0" + _d);
	    return _year + _month + _d;
	  }
	  // var stepType = "company";
	  // if("company"==stepType){
		 //  var table = document.getElementById("calendarTableLeft");
		 //  var tds = table.getElementsByTagName('td');
		 //  for(var i = 0; i < tds.length; i++) {
		 //    addEvent(tds[i], 'click', function(e){
		 //  			var tdById= document.getElementById(e.target.getAttribute('id'));
		 //  		  if(e.target.getAttribute('class')=="all day0"){
			// 		  console.log("触发")
			// 		// tdById.className = ' all mohthGetCashbox';
		 //  	// 		tdById.style="border:1px solid red ;"
		 //  	// 		tdById.innerHTML=tdById.innerHTML+'<span style="font-size: 5px;"  >去</span>'
		 //  		  }else if(e.target.getAttribute('class')=="mohthGetCashbox2"){
		  			
		 //  		  }else{
		 //  			  // tdById.className="all day0";
		 //  			  // tdById.style=""
		 //  			  // if(tdById.innerHTML.substr(0,2).indexOf("<")=="1"){
		 //  				 //   tdById.innerHTML=tdById.innerHTML.substr(0,1)
		 //  			  // }else{
		 //  				 //   tdById.innerHTML=tdById.innerHTML.substr(0,2)
		 //  			  // }
		 //  		  }
		 //    });
		 //  }
	  // }
	  
}












function creationMonthRight(titleName){
	var  allColour = $("#tickets").val();
	 titleName = $("#month").val();

	 //var workPlanTitle ="";
	  // 设置calendar div中的html部分
	  renderHtml();
	  // 表格中显示日期
	  showCalendarData();
	  // 绑定事件
	 // bindEvent();
	 
	  /**
	   * 渲染html结构
	   */
	  function renderHtml() {
	    var calendar = document.getElementById("calendar");
	    var titleBox = document.createElement("div");  // 标题盒子 设置上一月 下一月 标题
	    var bodyBox = document.createElement("div");  // 表格区 显示数据
	 
	    // 设置标题盒子中的html
	    titleBox.className = 'calendar-title-box';
	    titleBox.innerHTML = //"<span class='prev-month' id='prevMonth'></span>" +
	      "<span class='calendar-title' id='calendarTitle'></span>" 
	     // "<span id='nextMonth' class='next-month'></span>";
	    calendar.appendChild(titleBox);    // 添加到calendar div中
	 
	    // 设置表格区的html结构
	    bodyBox.className = 'calendar-body-box';
	    var _headHtml = "<tr >" + 
	              "<th style='text-align:center'>日</th>" +
	              "<th style='text-align:center'>一</th>" +
	              "<th style='text-align:center'>二</th>" +
	              "<th style='text-align:center'>三</th>" +
	              "<th style='text-align:center'>四</th>" +
	              "<th style='text-align:center'>五</th>" +
	              "<th style='text-align:center'>六</th>" +
	            "</tr>";
	    var _bodyHtml = "";
	
	 
	    // 一个月最多31天，所以一个月最多占6行表格
	    for(var i = 0; i < 6; i++) {  
	      _bodyHtml += "<tr>" +
	              "<td></td>" +
	              "<td></td>" +
	              "<td></td>" +
	              "<td></td>" +
	              "<td></td>" +
	              "<td></td>" +
	              "<td></td>" +
	            "</tr>";
	    }
	    bodyBox.innerHTML = "<table id='calendarTable' class='calendar-table'>" +
	              _headHtml + _bodyHtml +
	              "</table>";
	    // 添加到calendar div中
	    calendar.appendChild(bodyBox);
	  }
	 
	  /**
	   * 表格中显示数据，并设置类名
	   */
	  function showCalendarData() {
	    var _year =titleName.substr(0,4) //dateObj.getDate().getFullYear();
	    var _month = titleName.substr(4,2)//dateObj.getDate().getMonth() + 1;
		if(_month.indexOf("月")==1){
		_month = _month.substr(0,1);
		}
		/* if(){
			
		} */
	    var _dateStr = getDateStr(dateObj.getDate());
	 
	    // 设置顶部标题栏中的 年、月信息
	    var calendarTitle = document.getElementById("calendarTitle");
	    var titleStr = _year + "年" + _month+ "月";
	    calendarTitle.innerText = titleStr;
	 
	    // 设置表格中的日期数据
	    var _table = document.getElementById("calendarTable");
	    var _tds = _table.getElementsByTagName("td");
	    var _firstDay = new Date(_year, _month - 1, 1);  // 当前月第一天
	    for(var i = 0; i < _tds.length; i++) {
	      var _thisDay = new Date(_year, _month - 1, i + 1 - _firstDay.getDay());
	      var _thisDayStr = getDateStr(_thisDay);
	      _tds[i].innerText = _thisDay.getDate();
	      //_tds[i].data = _thisDayStr;
	      _tds[i].setAttribute('data', _thisDayStr);
	      if(_thisDayStr.substr(0, 6) == getDateStr(_firstDay).substr(0, 6)) {
			   var c=0;
			   _tds[i].className = 'all day0';
			   _tds[i].id=i+"id";
			   if("4"==allColour){
				   _tds[i].className = ' all mohthGetCashbox';
				   _tds[i].style="border:1px solid red ;"
				   _tds[i].innerHTML=_tds[i].innerHTML+'<span class="qwe"  style="font-size: 5px;"  >去</span>'
			   }
			 //  for(var w = 0;w<workPlanTitle.length;w++){
				  
				//  c++;
				// if(c<10){
				// 	c="0"+c;
				// }
				// if(_thisDayStr.substr(6, 8) ==c){
				// 	 _tds[i].id=workPlanTitle[w].id;
				// 	if("1"== workPlanTitle[w].day1){
				// 		_tds[i].className = ' all mohthGetCashbox';
				// 		 _tds[i].style="border:1px solid red ;"
				// 		 _tds[i].innerHTML=_tds[i].innerHTML+'<span class="qwe"  style="font-size: 5px;"  >去</span>'
				// 	}else{
						
				// 	}
					
				// 	if("2"== workPlanTitle[w].day1){
				// 		_tds[i].className = 'mohthGetCashbox2';
				// 		 _tds[i].style="border:1px solid red ;"
				// 		 _tds[i].innerHTML=_tds[i].innerHTML+'<span class="qwe"  style="font-size: 5px;"  >加急</span>'
				// 	}
				// }
			 //  }
			  
	       
	      }else {    // 其他月
	        _tds[i].className = 'otherMonth';
	      }
	    }
	  }
	 
	  /**
	   * 绑定上个月下个月事件
	   */
	  function bindEvent() {
	    var prevMonth = document.getElementById("prevMonth");
	    var nextMonth = document.getElementById("nextMonth");
	    addEvent(prevMonth, 'click', toPrevMonth);
	    addEvent(nextMonth, 'click', toNextMonth);
	  }
	 
	  /**
	   * 绑定事件
	   */
	  function addEvent(dom, eType, func) {
	    if(dom.addEventListener) {  // DOM 2.0
	      dom.addEventListener(eType, function(e){
	        func(e);
	      });
	    } else if(dom.attachEvent){  // IE5+
	      dom.attachEvent('on' + eType, function(e){
	        func(e);
	      });
	    } else {  // DOM 0
	      dom['on' + eType] = function(e) {
	        func(e);
	      }
	    }
	  }
	 
	  /**
	   * 点击上个月图标触发
	   */
	  function toPrevMonth() {
	    var date = dateObj.getDate();
	    dateObj.setDate(new Date(date.getFullYear(), date.getMonth() - 1, 1));
	    showCalendarData();
	  }
	 
	  /**
	   * 点击下个月图标触发
	   */
	  function toNextMonth() {
	    var date = dateObj.getDate();
	    dateObj.setDate(new Date(date.getFullYear(), date.getMonth() + 1, 1));
	    showCalendarData();
	  }
	 
	  /**
	   * 日期转化为字符串， 4位年+2位月+2位日
	   */
	  function getDateStr(date) {
	    var _year = date.getFullYear();
	    var _month = date.getMonth() + 1;    // 月从0开始计数
	    var _d = date.getDate();
	     
	    _month = (_month > 9) ? ("" + _month) : ("0" + _month);
	    _d = (_d > 9) ? ("" + _d) : ("0" + _d);
	    return _year + _month + _d;
	  }
		  var table = document.getElementById("calendarTable");
		  var tds = table.getElementsByTagName('td');
			  for(var i = 0; i < tds.length; i++) {
			    addEvent(tds[i], 'click', function(e){
			  		var tdById= document.getElementById(e.target.getAttribute('id'));
			  		  if(e.target.getAttribute('class')=="all day0"){
			  					tdById.className = ' all mohthGetCashbox';
			  			tdById.style="border:1px solid red ;"
			  			tdById.innerHTML=tdById.innerHTML+'<span style="font-size: 5px;"  >去</span>'
			  		  }else if(e.target.getAttribute('class')=="mohthGetCashbox2"){
			  			
			  		  }else{
			  			  tdById.className="all day0";
			  			  tdById.style=""
			  			  if(tdById.innerHTML.substr(0,2).indexOf("<")=="1"){
			  				   tdById.innerHTML=tdById.innerHTML.substr(0,1)
			  			  }else{
			  				   tdById.innerHTML=tdById.innerHTML.substr(0,2)
			  			  }
			  		  }
			    });
			  }
		
	 
}